/**
 * 获取URL参数
 * @param {string} search 查询字符串
 * @returns
 */
export const getUrlParams = (search = '') => {
  search = location.search
    ? location.search
    : location.hash === '#/'
    ? ''
    : location.hash

  const result = new Object()
  const str = search.includes('?') ? search.split('?')[1] : search

  if (search) {
    str.split('&').map((item) => {
      result[item.split('=')[0]] = decodeURIComponent(item.split('=')[1])
    })

    return result
  } else {
    return result
  }
}
